/*     */ package com.cr.web.controller.demo.controller;
/*     */ 
/*     */ import com.cr.common.core.controller.BaseController;
/*     */ import com.cr.common.core.domain.AjaxResult;
/*     */ import com.cr.common.core.page.PageDomain;
/*     */ import com.cr.common.core.page.TableDataInfo;
/*     */ import com.cr.common.core.page.TableSupport;
/*     */ import com.cr.common.core.text.Convert;
/*     */ import org.apache.commons.lang3.StringUtils;
/*     */ import com.cr.common.utils.poi.ExcelUtil;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Arrays;
/*     */ import java.util.Collections;
/*     */ import java.util.List;
/*     */ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
/*     */ import org.springframework.ui.ModelMap;
/*     */ import org.springframework.web.bind.annotation.GetMapping;
/*     */ import org.springframework.web.bind.annotation.PostMapping;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ import org.springframework.web.bind.annotation.ResponseBody;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/demo/table"})
/*     */ public class DemoTableController extends BaseController {
/*     */   private String prefix;
/*     */   
/*     */   public DemoTableController() {
/*  36 */     this.prefix = "demo/table";
/*  40 */     users.add(new UserTableModel(1, "1000001", "测试1", "0", "15888888888", "ry@qq.com", 150.0D, "0"));
/*  41 */     users.add(new UserTableModel(2, "1000002", "测试2", "1", "15666666666", "ry@qq.com", 180.0D, "1"));
/*  42 */     users.add(new UserTableModel(3, "1000003", "测试3", "0", "15666666666", "ry@qq.com", 110.0D, "1"));
/*  43 */     users.add(new UserTableModel(4, "1000004", "测试4", "1", "15666666666", "ry@qq.com", 220.0D, "1"));
/*  44 */     users.add(new UserTableModel(5, "1000005", "测试5", "0", "15666666666", "ry@qq.com", 140.0D, "1"));
/*  45 */     users.add(new UserTableModel(6, "1000006", "测试6", "1", "15666666666", "ry@qq.com", 330.0D, "1"));
/*  46 */     users.add(new UserTableModel(7, "1000007", "测试7", "0", "15666666666", "ry@qq.com", 160.0D, "1"));
/*  47 */     users.add(new UserTableModel(8, "1000008", "测试8", "1", "15666666666", "ry@qq.com", 170.0D, "1"));
/*  48 */     users.add(new UserTableModel(9, "1000009", "测试9", "0", "15666666666", "ry@qq.com", 180.0D, "1"));
/*  49 */     users.add(new UserTableModel(10, "1000010", "测试10", "0", "15666666666", "ry@qq.com", 210.0D, "1"));
/*  50 */     users.add(new UserTableModel(11, "1000011", "测试11", "1", "15666666666", "ry@qq.com", 110.0D, "1"));
/*  51 */     users.add(new UserTableModel(12, "1000012", "测试12", "0", "15666666666", "ry@qq.com", 120.0D, "1"));
/*  52 */     users.add(new UserTableModel(13, "1000013", "测试13", "1", "15666666666", "ry@qq.com", 380.0D, "1"));
/*  53 */     users.add(new UserTableModel(14, "1000014", "测试14", "0", "15666666666", "ry@qq.com", 280.0D, "1"));
/*  54 */     users.add(new UserTableModel(15, "1000015", "测试15", "0", "15666666666", "ry@qq.com", 570.0D, "1"));
/*  55 */     users.add(new UserTableModel(16, "1000016", "测试16", "1", "15666666666", "ry@qq.com", 260.0D, "1"));
/*  56 */     users.add(new UserTableModel(17, "1000017", "测试17", "1", "15666666666", "ry@qq.com", 210.0D, "1"));
/*  57 */     users.add(new UserTableModel(18, "1000018", "测试18", "1", "15666666666", "ry@qq.com", 340.0D, "1"));
/*  58 */     users.add(new UserTableModel(19, "1000019", "测试19", "1", "15666666666", "ry@qq.com", 160.0D, "1"));
/*  59 */     users.add(new UserTableModel(20, "1000020", "测试20", "1", "15666666666", "ry@qq.com", 220.0D, "1"));
/*  60 */     users.add(new UserTableModel(21, "1000021", "测试21", "1", "15666666666", "ry@qq.com", 120.0D, "1"));
/*  61 */     users.add(new UserTableModel(22, "1000022", "测试22", "1", "15666666666", "ry@qq.com", 130.0D, "1"));
/*  62 */     users.add(new UserTableModel(23, "1000023", "测试23", "1", "15666666666", "ry@qq.com", 490.0D, "1"));
/*  63 */     users.add(new UserTableModel(24, "1000024", "测试24", "1", "15666666666", "ry@qq.com", 570.0D, "1"));
/*  64 */     users.add(new UserTableModel(25, "1000025", "测试25", "1", "15666666666", "ry@qq.com", 250.0D, "1"));
/*  65 */     users.add(new UserTableModel(26, "1000026", "测试26", "1", "15666666666", "ry@qq.com", 250.0D, "1"));
/*  70 */     columns.add(new UserTableColumn("用户ID", "userId"));
/*  71 */     columns.add(new UserTableColumn("用户编号", "userCode"));
/*  72 */     columns.add(new UserTableColumn("用户姓名", "userName"));
/*  73 */     columns.add(new UserTableColumn("用户手机", "userPhone"));
/*  74 */     columns.add(new UserTableColumn("用户邮箱", "userEmail"));
/*  75 */     columns.add(new UserTableColumn("用户状态", "status"));
/*     */   }
/*     */   
/*     */   private static final List<UserTableModel> users = new ArrayList<>();
/*     */   
/*     */   private static final List<UserTableColumn> columns = new ArrayList<>();
/*     */   
/*     */   @GetMapping({"/search"})
/*     */   public String search() {
/*  84 */     return this.prefix + "/search";
/*     */   }
/*     */   
/*     */   @GetMapping({"/footer"})
/*     */   public String footer() {
/*  93 */     return this.prefix + "/footer";
/*     */   }
/*     */   
/*     */   @GetMapping({"/groupHeader"})
/*     */   public String groupHeader() {
/* 102 */     return this.prefix + "/groupHeader";
/*     */   }
/*     */   
/*     */   @GetMapping({"/export"})
/*     */   public String export() {
/* 111 */     return this.prefix + "/export";
/*     */   }
/*     */   
/*     */   @GetMapping({"/exportSelected"})
/*     */   public String exportSelected() {
/* 120 */     return this.prefix + "/exportSelected";
/*     */   }
/*     */   
/*     */   @PostMapping({"/exportData"})
/*     */   @ResponseBody
/*     */   public AjaxResult exportSelected(UserTableModel userModel, String userIds) {
/* 130 */     List<UserTableModel> userList = new ArrayList<>(Arrays.asList(new UserTableModel[users.size()]));
/* 131 */     Collections.copy(userList, users);
/* 134 */     if (StringUtils.isNotEmpty(userIds)) {
/* 136 */       userList.clear();
/* 137 */       for (Long userId : Convert.toLongArray(userIds)) {
/* 139 */         for (UserTableModel user : users) {
/* 141 */           if (user.getUserId() == userId.longValue())
/* 143 */             userList.add(user); 
/*     */         } 
/*     */       } 
/*     */     } 
/* 148 */     ExcelUtil<UserTableModel> util = new ExcelUtil(UserTableModel.class);
/* 149 */     return util.exportExcel(userList, "用户数据");
/*     */   }
/*     */   
/*     */   @GetMapping({"/remember"})
/*     */   public String remember() {
/* 158 */     return this.prefix + "/remember";
/*     */   }
/*     */   
/*     */   @GetMapping({"/pageGo"})
/*     */   public String pageGo() {
/* 167 */     return this.prefix + "/pageGo";
/*     */   }
/*     */   
/*     */   @GetMapping({"/params"})
/*     */   public String params() {
/* 176 */     return this.prefix + "/params";
/*     */   }
/*     */   
/*     */   @GetMapping({"/multi"})
/*     */   public String multi() {
/* 185 */     return this.prefix + "/multi";
/*     */   }
/*     */   
/*     */   @GetMapping({"/button"})
/*     */   public String button() {
/* 194 */     return this.prefix + "/button";
/*     */   }
/*     */   
/*     */   @GetMapping({"/data"})
/*     */   public String data(ModelMap mmap) {
/* 203 */     mmap.put("users", users);
/* 204 */     return this.prefix + "/data";
/*     */   }
/*     */   
/*     */   @GetMapping({"/fixedColumns"})
/*     */   public String fixedColumns() {
/* 213 */     return this.prefix + "/fixedColumns";
/*     */   }
/*     */   
/*     */   @GetMapping({"/event"})
/*     */   public String event() {
/* 222 */     return this.prefix + "/event";
/*     */   }
/*     */   
/*     */   @GetMapping({"/detail"})
/*     */   public String detail() {
/* 231 */     return this.prefix + "/detail";
/*     */   }
/*     */   
/*     */   @GetMapping({"/child"})
/*     */   public String child() {
/* 240 */     return this.prefix + "/child";
/*     */   }
/*     */   
/*     */   @GetMapping({"/image"})
/*     */   public String image() {
/* 249 */     return this.prefix + "/image";
/*     */   }
/*     */   
/*     */   @GetMapping({"/curd"})
/*     */   public String curd() {
/* 258 */     return this.prefix + "/curd";
/*     */   }
/*     */   
/*     */   @GetMapping({"/reorderRows"})
/*     */   public String reorderRows() {
/* 267 */     return this.prefix + "/reorderRows";
/*     */   }
/*     */   
/*     */   @GetMapping({"/reorderColumns"})
/*     */   public String reorderColumns() {
/* 276 */     return this.prefix + "/reorderColumns";
/*     */   }
/*     */   
/*     */   @GetMapping({"/resizable"})
/*     */   public String resizable() {
/* 285 */     return this.prefix + "/resizable";
/*     */   }
/*     */   
/*     */   @GetMapping({"/editable"})
/*     */   public String editable() {
/* 294 */     return this.prefix + "/editable";
/*     */   }
/*     */   
/*     */   @GetMapping({"/subdata"})
/*     */   public String subdata() {
/* 303 */     return this.prefix + "/subdata";
/*     */   }
/*     */   
/*     */   @GetMapping({"/refresh"})
/*     */   public String refresh() {
/* 312 */     return this.prefix + "/refresh";
/*     */   }
/*     */   
/*     */   @GetMapping({"/print"})
/*     */   public String print() {
/* 321 */     return this.prefix + "/print";
/*     */   }
/*     */   
/*     */   @GetMapping({"/headerStyle"})
/*     */   public String headerStyle() {
/* 330 */     return this.prefix + "/headerStyle";
/*     */   }
/*     */   
/*     */   @GetMapping({"/dynamicColumns"})
/*     */   public String dynamicColumns() {
/* 339 */     return this.prefix + "/dynamicColumns";
/*     */   }
/*     */   
/*     */   @GetMapping({"/customView"})
/*     */   public String customView() {
/* 348 */     return this.prefix + "/customView";
/*     */   }
/*     */   
/*     */   @GetMapping({"/other"})
/*     */   public String other() {
/* 357 */     return this.prefix + "/other";
/*     */   }
/*     */   
/*     */   @PostMapping({"/ajaxColumns"})
/*     */   @ResponseBody
/*     */   public AjaxResult ajaxColumns(UserTableColumn userColumn) {
/* 367 */     List<UserTableColumn> columnList = new ArrayList<>(Arrays.asList(new UserTableColumn[columns.size()]));
/* 368 */     Collections.copy(columnList, columns);
/* 369 */     if (userColumn != null && "userBalance".equals(userColumn.getField()))
/* 371 */       columnList.add(new UserTableColumn("用户余额", "userBalance")); 
/* 373 */     return AjaxResult.success(columnList);
/*     */   }
/*     */   
/*     */   @PostMapping({"/list"})
/*     */   @ResponseBody
/*     */   public TableDataInfo list(UserTableModel userModel) {
/* 383 */     TableDataInfo rspData = new TableDataInfo();
/* 384 */     List<UserTableModel> userList = new ArrayList<>(Arrays.asList(new UserTableModel[users.size()]));
/* 385 */     Collections.copy(userList, users);
/* 387 */     if (StringUtils.isNotEmpty(userModel.getUserName())) {
/* 389 */       userList.clear();
/* 390 */       for (UserTableModel user : users) {
/* 392 */         if (user.getUserName().equals(userModel.getUserName()))
/* 394 */           userList.add(user); 
/*     */       } 
/*     */     } 
/* 398 */     PageDomain pageDomain = TableSupport.buildPageRequest();
/* 399 */     if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize()) {
/* 401 */       rspData.setRows(userList);
/* 402 */       rspData.setTotal(userList.size());
/* 403 */       return rspData;
/*     */     } 
/* 405 */     Integer pageNum = Integer.valueOf((pageDomain.getPageNum().intValue() - 1) * 10);
/* 406 */     Integer pageSize = Integer.valueOf(pageDomain.getPageNum().intValue() * 10);
/* 407 */     if (pageSize.intValue() > userList.size())
/* 409 */       pageSize = Integer.valueOf(userList.size()); 
/* 411 */     rspData.setRows(userList.subList(pageNum.intValue(), pageSize.intValue()));
/* 412 */     rspData.setTotal(userList.size());
/* 413 */     return rspData;
/*     */   }
/*     */ }


/* Location:              D:\tmp\creditorRights-admin\BOOT-INF\classes\com.zip!\com\cr\web\controller\demo\controller\DemoTableController.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */